<!doctype html>



  


<html class="theme-next mist use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="baidu-site-verification" content="zD47G9xe42" />


<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="uiste个人博客网站,uiste,uiste博客,PHP,运维,Hexo,技术博客" />





  <link rel="alternate" href="/atom.xml" title="uiste" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta name="description" content="Stay Hungry，Stay Foolish">
<meta property="og:type" content="website">
<meta property="og:title" content="uiste">
<meta property="og:url" content="http://blog.uiste.com/page/2/index.html">
<meta property="og:site_name" content="uiste">
<meta property="og:description" content="Stay Hungry，Stay Foolish">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="uiste">
<meta name="twitter:description" content="Stay Hungry，Stay Foolish">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>




  <link rel="canonical" href="http://blog.uiste.com/page/2/"/>

  <title>
 
  uiste - Stay Hungry，Stay Foolish 

</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?b58b87af012832b8ae35e33bb45b44fa";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left 
   page-home 
 ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">uiste</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">uiste个人博客</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      

            <li class="menu-item menu-item-search"> <a title="把这个链接拖到你的Chrome收藏夹工具栏中" href='javascript:(function() {
    function c() {
        var e = document.createElement("link");
        e.setAttribute("type", "text/css");
        e.setAttribute("rel", "stylesheet");
        e.setAttribute("href", f);
        e.setAttribute("class", l);
        document.body.appendChild(e)
    }
 
    function h() {
        var e = document.getElementsByClassName(l);
        for (var t = 0; t < e.length; t++) {
            document.body.removeChild(e[t])
        }
    }
 
    function p() {
        var e = document.createElement("div");
        e.setAttribute("class", a);
        document.body.appendChild(e);
        setTimeout(function() {
            document.body.removeChild(e)
        }, 100)
    }
 
    function d(e) {
        return {
            height : e.offsetHeight,
            width : e.offsetWidth
        }
    }
 
    function v(i) {
        var s = d(i);
        return s.height > e && s.height < n && s.width > t && s.width < r
    }
 
    function m(e) {
        var t = e;
        var n = 0;
        while (!!t) {
            n += t.offsetTop;
            t = t.offsetParent
        }
        return n
    }
 
    function g() {
        var e = document.documentElement;
        if (!!window.innerWidth) {
            return window.innerHeight
        } else if (e && !isNaN(e.clientHeight)) {
            return e.clientHeight
        }
        return 0
    }
 
    function y() {
        if (window.pageYOffset) {
            return window.pageYOffset
        }
        return Math.max(document.documentElement.scrollTop, document.body.scrollTop)
    }
 
    function E(e) {
        var t = m(e);
        return t >= w && t <= b + w
    }
 
    function S() {
        var e = document.createElement("audio");
        e.setAttribute("class", l);
        e.src = i;
        e.loop = false;
        e.addEventListener("canplay", function() {
            setTimeout(function() {
                x(k)
            }, 500);
            setTimeout(function() {
                N();
                p();
                for (var e = 0; e < O.length; e++) {
                    T(O[e])
                }
            }, 15500)
        }, true);
        e.addEventListener("ended", function() {
            N();
            h()
        }, true);
        e.innerHTML = " <p>If you are reading this, it is because your browser does not support the audio element. We recommend that you get a new browser.</p> <p>";
        document.body.appendChild(e);
        e.play()
    }
 
    function x(e) {
        e.className += " " + s + " " + o
    }
 
    function T(e) {
        e.className += " " + s + " " + u[Math.floor(Math.random() * u.length)]
    }
 
    function N() {
        var e = document.getElementsByClassName(s);
        var t = new RegExp("\\b" + s + "\\b");
        for (var n = 0; n < e.length; ) {
            e[n].className = e[n].className.replace(t, "")
        }
    }
 
    var e = 30;
    var t = 30;
    var n = 350;
    var r = 350;
    var i = "//s3.amazonaws.com/moovweb-marketing/playground/harlem-shake.mp3";
    var s = "mw-harlem_shake_me";
    var o = "im_first";
    var u = ["im_drunk", "im_baked", "im_trippin", "im_blown"];
    var a = "mw-strobe_light";
    var f = "//s3.amazonaws.com/moovweb-marketing/playground/harlem-shake-style.css";
    var l = "mw_added_css";
    var b = g();
    var w = y();
    var C = document.getElementsByTagName("*");
    var k = null;
    for (var L = 0; L < C.length; L++) {
        var A = C[L];
        if (v(A)) {
            if (E(A)) {
                k = A;
                break
            }
        }
    }
    if (A === null) {
        console.warn("Could not find a node of the right size. Please try a different page.");
        return
    }
    c();
    S();
    var O = [];
    for (var L = 0; L < C.length; L++) {
        var A = C[L];
        if (v(A)) {
            O.push(A)
        }
    }
})()    '>High</a> </li>

    </ul>
  

 
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
   
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/20161017-3.html" itemprop="url">
                  数据库设计-商城购物系统
                </a>
              
            
          </h1>
        

        <div class="post-meta">
        
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-10-17T02:43:08+08:00" content="2016-10-17">
              2016-10-17
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/20161017-3.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="20161017-3.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="数据库设计"><a href="#数据库设计" class="headerlink" title="数据库设计"></a>数据库设计</h2><figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div><div class="line">141</div><div class="line">142</div><div class="line">143</div><div class="line">144</div><div class="line">145</div><div class="line">146</div><div class="line">147</div><div class="line">148</div><div class="line">149</div><div class="line">150</div><div class="line">151</div><div class="line">152</div><div class="line">153</div><div class="line">154</div><div class="line">155</div><div class="line">156</div><div class="line">157</div><div class="line">158</div><div class="line">159</div><div class="line">160</div><div class="line">161</div><div class="line">162</div><div class="line">163</div><div class="line">164</div><div class="line">165</div><div class="line">166</div><div class="line">167</div><div class="line">168</div><div class="line">169</div><div class="line">170</div><div class="line">171</div><div class="line">172</div><div class="line">173</div><div class="line">174</div><div class="line">175</div><div class="line">176</div><div class="line">177</div><div class="line">178</div><div class="line">179</div><div class="line">180</div><div class="line">181</div><div class="line">182</div><div class="line">183</div><div class="line">184</div><div class="line">185</div><div class="line">186</div><div class="line">187</div><div class="line">188</div><div class="line">189</div><div class="line">190</div><div class="line">191</div><div class="line">192</div><div class="line">193</div><div class="line">194</div><div class="line">195</div><div class="line">196</div><div class="line">197</div><div class="line">198</div><div class="line">199</div><div class="line">200</div><div class="line">201</div><div class="line">202</div><div class="line">203</div><div class="line">204</div><div class="line">205</div><div class="line">206</div><div class="line">207</div><div class="line">208</div><div class="line">209</div><div class="line">210</div><div class="line">211</div><div class="line">212</div><div class="line">213</div><div class="line">214</div><div class="line">215</div><div class="line">216</div><div class="line">217</div><div class="line">218</div><div class="line">219</div><div class="line">220</div><div class="line">221</div><div class="line">222</div><div class="line">223</div><div class="line">224</div><div class="line">225</div><div class="line">226</div><div class="line">227</div><div class="line">228</div><div class="line">229</div><div class="line">230</div><div class="line">231</div><div class="line">232</div><div class="line">233</div><div class="line">234</div><div class="line">235</div><div class="line">236</div><div class="line">237</div><div class="line">238</div><div class="line">239</div><div class="line">240</div><div class="line">241</div><div class="line">242</div><div class="line">243</div><div class="line">244</div><div class="line">245</div><div class="line">246</div><div class="line">247</div><div class="line">248</div><div class="line">249</div><div class="line">250</div><div class="line">251</div><div class="line">252</div><div class="line">253</div><div class="line">254</div><div class="line">255</div><div class="line">256</div><div class="line">257</div><div class="line">258</div><div class="line">259</div><div class="line">260</div><div class="line">261</div><div class="line">262</div><div class="line">263</div><div class="line">264</div><div class="line">265</div><div class="line">266</div><div class="line">267</div><div class="line">268</div><div class="line">269</div><div class="line">270</div><div class="line">271</div><div class="line">272</div><div class="line">273</div><div class="line">274</div><div class="line">275</div><div class="line">276</div><div class="line">277</div><div class="line">278</div><div class="line">279</div><div class="line">280</div><div class="line">281</div><div class="line">282</div><div class="line">283</div><div class="line">284</div><div class="line">285</div><div class="line">286</div><div class="line">287</div><div class="line">288</div><div class="line">289</div><div class="line">290</div><div class="line">291</div><div class="line">292</div><div class="line">293</div><div class="line">294</div><div class="line">295</div><div class="line">296</div><div class="line">297</div><div class="line">298</div><div class="line">299</div><div class="line">300</div><div class="line">301</div><div class="line">302</div><div class="line">303</div><div class="line">304</div><div class="line">305</div><div class="line">306</div><div class="line">307</div><div class="line">308</div></pre></td><td class="code"><pre><div class="line">/*</div><div class="line"> Navicat Premium Data Transfer</div><div class="line"></div><div class="line"> Source Server         : uiste</div><div class="line"> Source Server Type    : MySQL</div><div class="line"> Source Server Version : 50542</div><div class="line"> Source Host           : localhost</div><div class="line"> Source Database       : ugo</div><div class="line"></div><div class="line"> Target Server Type    : MySQL</div><div class="line"> Target Server Version : 50542</div><div class="line"> File Encoding         : utf-8</div><div class="line"></div><div class="line"> Date: 10/16/2016 14:27:21 PM</div><div class="line">*/</div><div class="line"></div><div class="line">#创建数据库</div><div class="line">create database ugo charset utf8;</div><div class="line">#选择数据库</div><div class="line">use ugou;</div><div class="line"></div><div class="line">/*------------------------------------商品模块---------------------------------------*/</div><div class="line">#创建商品类别表</div><div class="line">DROP TABLE IF EXISTS `ugo_category`;</div><div class="line">create table ugo_category(</div><div class="line">	cat_id smallint unsigned not null auto_increment primary key comment '商品类别ID',</div><div class="line">	cat_name varchar(30) not null default '' comment '商品类别名称',</div><div class="line">	cat_parent_id smallint unsigned not null default 0 comment '商品类别父ID',</div><div class="line">	cat_desc varchar(255) not null default '' comment '商品类别描述',</div><div class="line">	sort_order tinyint not null default 50 comment '排序依据',</div><div class="line">	unit varchar(15) not null default '' comment '单位',</div><div class="line">	is_show tinyint not null default 1 comment '是否显示，默认显示',</div><div class="line">	index pid(cat_parent_id)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建商品国家表</div><div class="line">DROP TABLE IF EXISTS `ugo_country`;</div><div class="line">create table ugo_country(</div><div class="line">	country_id smallint unsigned not null auto_increment primary key comment '国家ID',</div><div class="line">	country_name varchar(30) not null default '' comment '国家名称',</div><div class="line">	country_parent_name enum('亚洲','欧洲','北美洲','南美洲','非洲','大洋洲','南极洲') not null default '亚洲' comment '国家所属区域',</div><div class="line">	sort_order tinyint not null default 50 comment '排序依据',</div><div class="line">	is_show tinyint not null default 1 comment '是否显示，默认显示',</div><div class="line">	index pid(country_parent_name)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建商品品牌表</div><div class="line">DROP TABLE IF EXISTS `ugo_brand`;</div><div class="line">create table ugo_brand(</div><div class="line">	brand_id smallint unsigned not null auto_increment primary key comment '商品品牌ID',</div><div class="line">	brand_name varchar(30) not null default '' comment '商品品牌名称',</div><div class="line">	brand_desc varchar(255) not null default '' comment '商品品牌描述',</div><div class="line">	url varchar(100) not null default '' comment '商品品牌网址',</div><div class="line">	logo varchar(50) not null default '' comment '品牌logo',</div><div class="line">	sort_order tinyint unsigned not null default 50 comment '商品品牌排序依据',</div><div class="line">	is_show tinyint not null default 1 comment '是否显示，默认显示',</div><div class="line">	country_id smallint unsigned not null comment '商品品牌所属国家ID'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建商品类型表</div><div class="line">DROP TABLE IF EXISTS `ugo_attrtype`;</div><div class="line">create table ugo_attrtype(</div><div class="line">	type_id smallint unsigned not null auto_increment primary key comment '商品类型ID',</div><div class="line">	type_name varchar(50) not null default '' comment '商品类型名称'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line"></div><div class="line">#创建商品属性表</div><div class="line">DROP TABLE IF EXISTS `ugo_attribute`;</div><div class="line">create table ugo_attribute(</div><div class="line">	attr_id smallint unsigned not null auto_increment primary key comment '商品属性ID',</div><div class="line">	attr_name varchar(50) not null default '' comment '商品属性名称',</div><div class="line">	type_id smallint not null default 0 comment '商品属性所属类型ID',</div><div class="line">	attr_input_type tinyint not null default 1 comment '属性录入方式 0为手工录入，1为从列表中选择，2为文本域',</div><div class="line">	attr_input_value text comment '属性的值',</div><div class="line">	index type_id(type_id)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建商品表</div><div class="line">DROP TABLE IF EXISTS `ugo_goods`;</div><div class="line">create table ugo_goods(</div><div class="line">	goods_id int unsigned not null auto_increment primary key comment '商品ID',</div><div class="line">	goods_sn varchar(30) not null default '' comment '商品货号',</div><div class="line">	goods_name varchar(100) not null default '' comment '商品名称',</div><div class="line">	goods_brief varchar(255) not null default '' comment '商品简单描述',</div><div class="line">	goods_slogan varchar(50) not null default '' comment '商品宣传语',</div><div class="line">	goods_desc text comment '商品详情',</div><div class="line">	cat_id smallint unsigned not null default 0 comment '商品所属类别ID',</div><div class="line">	brand_id smallint unsigned not null default 0 comment '商品所属品牌ID',</div><div class="line">	market_price decimal(10,2) not null default 0 comment '市场价格',</div><div class="line">	promote_price decimal(10,2) not null default 0 comment '促销价格',</div><div class="line">	promote_start_time int unsigned not null default 0 comment '促销起始时间',</div><div class="line">	promote_end_time int unsigned not null default 0 comment '促销截止时间',</div><div class="line">	goods_img varchar(50) not null default '' comment '商品图片',</div><div class="line">	goods_thumb varchar(50) not null default '' comment '商品缩略图',</div><div class="line">	goods_number smallint unsigned not null default 0 comment '商品库存',</div><div class="line">	click_count int unsigned not null default 0 comment '点击次数',</div><div class="line">	type_id smallint unsigned not null default 0 comment '商品类型ID',</div><div class="line">	is_promote tinyint unsigned not null default 0 comment '是否促销，默认为0不促销',</div><div class="line">	is_best tinyint unsigned not null default 0 comment '是否精品,默认为0',</div><div class="line">	is_new tinyint unsigned not null default 0 comment '是否新品，默认为0',</div><div class="line">	is_hot tinyint unsigned not null default 0 comment '是否热卖,默认为0',</div><div class="line">	is_onsale tinyint unsigned not null default 1 comment '是否上架,默认为1',</div><div class="line">	add_time int unsigned not null default 0 comment '添加时间',</div><div class="line">	index cat_id(cat_id),</div><div class="line">	index brand_id(brand_id),</div><div class="line">	index type_id(type_id)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建商品属性对应表</div><div class="line">DROP TABLE IF EXISTS `ugo_goods_attr`;</div><div class="line">create table ugo_goods_attr(</div><div class="line">	goods_attr_id int unsigned not null auto_increment primary key comment '编号ID',</div><div class="line">	goods_id int unsigned not null default 0 comment '商品ID',</div><div class="line">	attr_id smallint unsigned not null default 0 comment '属性ID',</div><div class="line">	attr_value varchar(255) not null default '' comment '属性值',</div><div class="line">	attr_price decimal(10,2) not null default 0 comment '属性价格',</div><div class="line">	index goods_id(goods_id),</div><div class="line">	index attr_id(attr_id)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建商品相册表</div><div class="line">DROP TABLE IF EXISTS `ugo_gallery`;</div><div class="line">create table ugo_gallery(</div><div class="line">	img_id int unsigned not null auto_increment primary key comment '图片编号',</div><div class="line">	goods_id int unsigned not null default 0 comment '商品ID',</div><div class="line">	img_url varchar(50) not null default '' comment '图片URL',</div><div class="line">	thumb_url varchar(50) not null default '' comment '缩略图URL',</div><div class="line">	img_desc varchar(50) not null default '' comment '图片描述',</div><div class="line">	index goods_id(goods_id)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">/*------------------------------------商品模块 end-----------------------------------*/</div><div class="line"></div><div class="line"></div><div class="line">/*------------------------------------用户模块---------------------------------------*/</div><div class="line">#创建用户表</div><div class="line">DROP TABLE IF EXISTS `ugo_user`;</div><div class="line">create table ugo_user(</div><div class="line">	user_id int unsigned not null auto_increment primary key comment '用户编号',</div><div class="line">	user_name varchar(50) not null default '' comment '用户名',</div><div class="line">	tel char(12) not null default '' comment '手机号码',</div><div class="line">	email varchar(50) not null default '' comment '电子邮箱',</div><div class="line">	password char(32) not null default '' comment '用户密码,md5加密',</div><div class="line">	reg_time int unsigned not null default 0 comment '用户注册时间'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建用户收货地址表</div><div class="line">DROP TABLE IF EXISTS `ugo_address`;</div><div class="line">create table ugo_address(</div><div class="line">	address_id int unsigned not null auto_increment primary key comment '地址编号',</div><div class="line">	user_id int unsigned not null default 0 comment '地址所属用户ID',</div><div class="line">	consignee varchar(60) not null default '' comment '收货人姓名',</div><div class="line">	province smallint unsigned not null default 0 comment '省份，保存是ID',</div><div class="line">	city smallint unsigned not null default 0 comment '市',</div><div class="line">	district smallint unsigned not null default 0 comment '区',</div><div class="line">	street varchar(100) not null default '' comment '街道地址',</div><div class="line">	zipcode varchar(10) not null default '' comment '邮政编码',</div><div class="line">	telephone varchar(20) not null default '' comment '电话',</div><div class="line">	mobile varchar(20) not null default '' comment '移动电话',</div><div class="line">	index user_id(user_id)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建地区表，包括省市区三级</div><div class="line">DROP TABLE IF EXISTS `ugo_region`;</div><div class="line">create table ugo_region(</div><div class="line">	region_id smallint unsigned not null auto_increment primary key comment '地区ID',</div><div class="line">	parent_id smallint unsigned not null default 0 comment '父ID',</div><div class="line">	region_name varchar(30) not null default '' comment '地区名称',</div><div class="line">	region_type tinyint unsigned not null default 1 comment '地区类型 1 省份 2 市 3 区(县)'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建购物车表</div><div class="line">DROP TABLE IF EXISTS `ugo_cart`;</div><div class="line">create table ugo_cart(</div><div class="line">	cart_id int unsigned not null auto_increment primary key comment '购物车ID',</div><div class="line">	user_id int unsigned not null default 0 comment '用户ID',</div><div class="line">	goods_id int unsigned not null default 0 comment '商品ID',</div><div class="line">	goods_name varchar(100) not null default '' comment '商品名称',</div><div class="line">	goods_img varchar(50) not null default '' comment '商品图片',</div><div class="line">	goods_attr varchar(255) not null default '' comment '商品属性',</div><div class="line">	goods_number smallint unsigned not null default 1 comment '商品数量',</div><div class="line">	market_price decimal(10,2) not null default 0 comment '市场价格',</div><div class="line">	goods_price decimal(10,2) not null default 0 comment '成交价格',</div><div class="line">	subtotal decimal(10,2) not null default 0 comment '小计'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line">/*------------------------------------用户模块 end-----------------------------------*/</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line">/*------------------------------------订单模块---------------------------------------*/</div><div class="line">#创建送货方式表</div><div class="line">DROP TABLE IF EXISTS `ugo_shipping`;</div><div class="line">create table ugo_shipping(</div><div class="line">	shipping_id tinyint unsigned not null auto_increment primary key comment '编号',</div><div class="line">	shipping_name varchar(30) not null default '' comment '送货方式名称',</div><div class="line">	shipping_desc varchar(255) not null default '' comment '送货方式描述',</div><div class="line">	shipping_fee decimal(10,2) not null default 0 comment '送货费用',</div><div class="line">	enabled tinyint unsigned not null default 1 comment '是否启用，默认启用'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line"></div><div class="line">#创建支付方式表</div><div class="line">DROP TABLE IF EXISTS `ugo_payment`;</div><div class="line">create table ugo_payment(</div><div class="line">	pay_id tinyint unsigned not null auto_increment primary key comment '支付方式ID',</div><div class="line">	pay_name varchar(30) not null default '' comment '支付方式名称',</div><div class="line">	pay_desc varchar(255) not null default '' comment '支付方式描述',</div><div class="line">	enabled tinyint unsigned not null default 1 comment '是否启用，默认启用'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line"></div><div class="line">#创建订单表</div><div class="line">DROP TABLE IF EXISTS `ugo_order`;</div><div class="line">create table ugo_order(</div><div class="line">	order_id int unsigned not null auto_increment primary key comment '订单ID',</div><div class="line">	order_sn varchar(30) not null default '' comment '订单号',</div><div class="line">	user_id int unsigned not null default 0 comment '用户ID',</div><div class="line">	address_id int unsigned not null default 0 comment '收货地址id',</div><div class="line">	order_status tinyint unsigned not null default 0 comment '订单状态 1 待付款 2 待发货 3 已发货 4 已完成',</div><div class="line">	postscripts varchar(255) not null default '' comment '订单附言',</div><div class="line">	shipping_id tinyint not null default 0 comment '送货方式ID',</div><div class="line">	pay_id tinyint not null default 0 comment '支付方式ID',</div><div class="line">	goods_amount decimal(10,2) not null default 0 comment '商品总金额',</div><div class="line">	order_amount decimal(10,2) not null default 0 comment '订单总金额',</div><div class="line">	order_time int unsigned not null default 0 comment '下单时间',</div><div class="line">	index user_id(user_id),</div><div class="line">	index address_id(address_id),</div><div class="line">	index pay_id(pay_id),</div><div class="line">	index shipping_id(shipping_id)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line"></div><div class="line">#创建订单明细表,即商品订单关系表（多对多）</div><div class="line">DROP TABLE IF EXISTS `ugo_order_goods`;</div><div class="line">create table ugo_order_goods(</div><div class="line">	rec_id int unsigned not null auto_increment primary key comment '编号',</div><div class="line">	order_id int unsigned not null default 0 comment '订单ID',</div><div class="line">	goods_id int unsigned not null default 0 comment '商品ID',</div><div class="line">	goods_name varchar(100) not null default '' comment '商品名称',</div><div class="line">	goods_img varchar(50) not null default '' comment '商品图片',</div><div class="line">	shop_price decimal(10,2) not null default 0 comment '商品价格',</div><div class="line">	goods_price decimal(10,2) not null default 0 comment '成交价格',</div><div class="line">	goods_number smallint unsigned not null default 1 comment '购买数量',</div><div class="line">	goods_attr varchar(255) not null default '' comment '商品属性',</div><div class="line">	subtotal decimal(10,2) not null default 0 comment '商品小计'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">/*------------------------------------订单模块 end-----------------------------------*/</div><div class="line">#创建后台管理员表</div><div class="line">DROP TABLE IF EXISTS ugo_admin;</div><div class="line">CREATE TABLE ugo_admin(</div><div class="line">	admin_id TINYINT UNSIGNED auto_increment PRIMARY KEY COMMENT '管理员id' ,</div><div class="line">	admin_name VARCHAR(50) NOT NULL COMMENT '用户名' ,</div><div class="line">	admin_pwd VARCHAR(50) NOT NULL COMMENT '密码' ,</div><div class="line">	admin_role_id TINYINT UNSIGNED NOT NULL COMMENT '角色编号'</div><div class="line">) ENGINE = INNODB charset = utf8 COMMENT '管理员表';</div><div class="line"># 超级管理员测试数据</div><div class="line">insert into ugo_admin values (null,'aa','aa',0);</div><div class="line"></div><div class="line">#创建后台权限表</div><div class="line">DROP TABLE IF EXISTS ugo_authority;</div><div class="line">CREATE TABLE ugo_authority(</div><div class="line">	auth_id INT UNSIGNED auto_increment PRIMARY KEY COMMENT 'auth_id' ,</div><div class="line">	auth_name VARCHAR(50) NOT NULL COMMENT '权限名称' ,</div><div class="line">	auth_pid INT UNSIGNED NOT NULL COMMENT '权限父级id' ,</div><div class="line">	auth_c VARCHAR(50) NULL COMMENT '控制器名' ,</div><div class="line">	auth_a VARCHAR(50) NULL COMMENT '方法名' ,</div><div class="line">	auth_path VARCHAR(50) NULL COMMENT '全路径,格式:父级id-子级id' ,</div><div class="line">	is_show TINYINT NOT NULL DEFAULT 1 COMMENT '是否显示在导航栏上'</div><div class="line">) ENGINE = INNODB charset = utf8 COMMENT '权限表';</div><div class="line"></div><div class="line">#创建后台角色表</div><div class="line">DROP TABLE IF EXISTS ugo_role;</div><div class="line">CREATE TABLE IF NOT EXISTS ugo_role(</div><div class="line">	role_id TINYINT UNSIGNED auto_increment PRIMARY KEY COMMENT 'role_id' ,</div><div class="line">	role_name VARCHAR(50) NOT NULL COMMENT '角色名称' ,</div><div class="line">	role_auth_ids VARCHAR(255) NOT NULL COMMENT '角色具有权限id的集合，格式1,2,5' ,</div><div class="line">	role_auth_ac text NOT NULL COMMENT '控制器和方法的组合，格式：控制器-方法名'</div><div class="line">) ENGINE = INNODB charset = utf8 COMMENT '角色表';</div><div class="line"></div><div class="line"># *********************************************************** #</div><div class="line">-- 插入测试数据</div><div class="line">insert into ugo_authority values (1,'商品管理',0,'','',1,1);</div><div class="line">insert into ugo_authority values (2,'会员管理',0,'','',2,1);</div><div class="line">insert into ugo_authority values (3,'权限管理',0,'','',3,1);</div><div class="line"></div><div class="line">insert into ugo_authority values (4,'商品列表',1,'Goods','show','1-4',1);</div><div class="line">insert into ugo_authority values (5,'添加商品',1,'Goods','add','1-5',1);</div><div class="line">insert into ugo_authority values (6,'修改商品',1,'Goods','edit','1-6',0);</div><div class="line">insert into ugo_authority values (7,'删除商品',1,'Goods','del','1-7',0);</div><div class="line"></div><div class="line">insert into ugo_authority values (8,'会员列表',2,'Role','show','2-12',1);</div><div class="line">insert into ugo_authority values (9,'添加会员',2,'Role','add','2-13',1);</div><div class="line">insert into ugo_authority values (10,'修改会员',2,'Role','edit','2-14',0);</div><div class="line">insert into ugo_authority values (11,'删除会员',2,'Role','del','2-15',0);</div><div class="line"></div><div class="line">insert into ugo_authority values (12,'权限列表',3,'Authority','show','3-8',1);</div><div class="line">insert into ugo_authority values (13,'添加权限',3,'Authority','add','3-9',1);</div><div class="line">insert into ugo_authority values (14,'修改权限',3,'Authority','edit','3-10',0);</div><div class="line">insert into ugo_authority values (15,'删除权限',3,'Authority','del','3-11',0);</div><div class="line"></div><div class="line">insert into ugo_role values (1,'经理','1,4,5','Goods-show,Goods-add');</div><div class="line">insert into ugo_role values (2,'主管','1,4','Goods-show');</div><div class="line"></div><div class="line">insert into ugo_admin values (null,'aa','aa',0)</div><div class="line"># *********************************************************** #</div></pre></td></tr></table></figure>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/20161017-2.html" itemprop="url">
                  模板引擎
                </a>
              
            
          </h1>
        

        <div class="post-meta">
        
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-10-17T02:41:37+08:00" content="2016-10-17">
              2016-10-17
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/20161017-2.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="20161017-2.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="前台页面实现、Smarty"><a href="#前台页面实现、Smarty" class="headerlink" title="前台页面实现、Smarty"></a>前台页面实现、Smarty</h1><h3 id="static-和-GLOBALS的区别"><a href="#static-和-GLOBALS的区别" class="headerlink" title="static 和 GLOBALS的区别"></a>static 和 GLOBALS的区别</h3><p>相同点：生命周期是一样的，声明的时候产生，页面执行完毕销毁。<br>不同点：</p>
<blockquote>
<p>超全局变量在所有的地方都能使用<br>静态变量只能在自己的作用域中访问<br>如果一个函数内没有区别，两个函数只能GLOBALS作用域不同</p>
</blockquote>
<h3 id="前台显示"><a href="#前台显示" class="headerlink" title="前台显示"></a>前台显示</h3><p>实现方法：<br>1、递归<br>2、三重循环</p>
<blockquote>
<p>在开发的时候能不用递归就不用递归，因为递归消耗资源比较多；如果确定就显示三级就用三重循环来实现</p>
</blockquote>
<p>方法一：通过模糊查询<br><code>select * from goods where `goods_status` like &#39;%hot%&#39;;</code></p>
<blockquote>
<p>模糊查询，以<code>%</code>百分号开头的查询无法使用索引，只能是全表扫描。效率低下</p>
</blockquote>
<p>方法二：使用find_in_set(值，集合)<br><code>select * from goods where find_in_set(&#39;best&#39;,`goods_status`);</code></p>
<blockquote>
<p>优化了方法一，效率提高了。但<code>find_in_set()</code>函数本身是个全表扫描的函数</p>
</blockquote>
<p>方法三：使用位运算符<br>查找best：<br><code>select * from goods where goods_status &amp; 1;</code><br>查找既有best又有hot同时存在：<br><code>select * from goods where goods_status &amp; 1 and goods_status &amp; 4</code> </p>
<blockquote>
<p>集合和枚举一样，在计算机内部都是通过数值管理的。<br>要想看有没有那个参数，就与上那个参数就可以了。<code>&amp;</code><br>best =&gt; 001<br>new =&gt; 010<br>hot   =&gt; 100<br>测试：select goods_status,goods_status+0 from goods;<br>best,new       3<br>best,new,hot 7<br>new,hot         6</p>
<p>best+hot<br>  101<br>&amp;001<br>  001</p>
</blockquote>
<p><strong>已知集合占用8个字节，一个字节8个位，8个直接64个位，所有集合最多可以保存64个选项</strong></p>
<h1 id="模板引擎"><a href="#模板引擎" class="headerlink" title="模板引擎"></a>模板引擎</h1><p>引擎和框架是有区别的。<br>我们现在开发的项目，前段代码和服务器端代码同在一个页面中。这样前端和服务器端看起来都不方便。为了让所有的项目开发人员。只关注自己的业务，我们将表现（HTML）和内容（PHP）相分离。</p>
<h2 id="模板引擎-推导"><a href="#模板引擎-推导" class="headerlink" title="模板引擎 推导"></a>模板引擎 推导</h2><p>简而言之，界定符的优化。将输出变量更改一下形式<br>光说不练假把式<br>将替换的结果当成字符串输出了。</p>
<h3 id="模板引擎的思想四步法："><a href="#模板引擎的思想四步法：" class="headerlink" title="模板引擎的思想四步法："></a>模板引擎的思想四步法：</h3><p><code>file_get_contents();</code> 获取表现内容<br><code>str_replace();</code>  定义左右定界符<br><code>file_put_contents();</code> 输出混编文件<br><code>require();</code> 引入混编文件</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span> </div><div class="line">$str = file_get_contents(<span class="string">'demo.html'</span>);</div><div class="line">$str = str_replace(<span class="string">'&#123;'</span>,<span class="string">'&lt;?php echo '</span>,$str);</div><div class="line">$str = str_replace(<span class="string">'&#125;'</span>,<span class="string">";?&gt;"</span>,$str);</div><div class="line">file_put_contents(<span class="string">'./demo.html.php'</span>,$str);</div><div class="line"><span class="keyword">require</span> <span class="string">'./demo.html.php'</span>;</div><div class="line"> <span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<h3 id="模板引擎封装"><a href="#模板引擎封装" class="headerlink" title="模板引擎封装"></a>模板引擎封装</h3><figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span> </div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">Smarty</span></span>&#123;</div><div class="line">	<span class="keyword">private</span> $tpl_var=<span class="keyword">array</span>();</div><div class="line">	<span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">assign</span><span class="params">($key,$value)</span></span>&#123;</div><div class="line">		<span class="keyword">$this</span>-&gt;tpl_var[$Key]=$value;</div><div class="line">	&#125;</div><div class="line">	<span class="comment">//@param string $tpl HTML页面的地址</span></div><div class="line">	pulic <span class="function"><span class="keyword">function</span> <span class="title">compile</span><span class="params">($tpl)</span></span>&#123;</div><div class="line">		$com_file = $tpl.<span class="string">'.php'</span>;<span class="comment">//混编文件名complicated</span></div><div class="line">		<span class="keyword">if</span>(file_exists($com_file) &amp;&amp; filemtime($tpl)&lt;filetime($com_file))&#123;</div><div class="line">			<span class="keyword">require</span> $com_file;</div><div class="line">		&#125;<span class="keyword">else</span>&#123;</div><div class="line">		$str = file_get_contents(<span class="string">'demo.html'</span>);</div><div class="line">		$str = str_replace(<span class="string">'&#123;'</span>,<span class="string">'&lt;?php echo $this-&gt;tpl_var[\''</span>,$str);</div><div class="line">		$str = str_replace(<span class="string">'&#125;'</span>,<span class="string">"\'];?&gt;"</span>,$str);</div><div class="line">		file_put_contents(<span class="string">'./demo.html.php'</span>,$str);</div><div class="line">		<span class="keyword">require</span> $com_file;</div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">&#125;</div><div class="line">$smarty = <span class="keyword">new</span> Smarty();</div><div class="line">$smarty-&gt;assign(<span class="string">'title'</span>,$title);</div><div class="line">$smarty-&gt;compile(demo.html);</div><div class="line"> <span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<p>输出：<br><code>&lt;?php echo $this-&gt;tpl_var[$key]?&gt;</code></p>
<p>外部调用<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">require &apos;./Smarty.class.php&apos;; //加载类文件</div><div class="line">$smarty = new Smarty(); //实例化对象</div><div class="line">$smarty-&gt;assgin(&apos;title&apos;,$title); //赋值操作</div><div class="line">$smarty-&gt;compile(); //编译输出文件</div></pre></td></tr></table></figure></p>
<p>如何判断混编文件不是最新的?</p>
<blockquote>
<p>模板的创建时间在混编文件之前<code>int filemtime ( string $filename )</code></p>
</blockquote>
<p>将模板文件和混编文件分开存储</p>
<ul>
<li>templates</li>
<li>templates_c</li>
</ul>
<p>一般来说，关键性代码都是私有，通过公有的方法来调用它；</p>
<ul>
<li>将complie() 方法用private来修饰，用一个公有的方法来调用display()调用</li>
</ul>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/20161017-1.html" itemprop="url">
                  Smarty2 模板引擎
                </a>
              
            
          </h1>
        

        <div class="post-meta">
        
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-10-17T02:40:34+08:00" content="2016-10-17">
              2016-10-17
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/20161017-1.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="20161017-1.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="Smarty-模板引擎"><a href="#Smarty-模板引擎" class="headerlink" title="Smarty 模板引擎"></a>Smarty 模板引擎</h1><h2 id="Smarty作用"><a href="#Smarty作用" class="headerlink" title="Smarty作用"></a>Smarty作用</h2><p>Smarty 是一个成熟的引擎，用来实现表现和内容相分离。<br><a href="www.smarty.net">Smarty官网</a></p>
<blockquote>
<p>文件目录</p>
<ul>
<li><code>plugins</code> 存放Smarty插件，即扩展类文件</li>
<li><code>sysplugins</code> 存放系统系统函数的目录</li>
<li><code>Smarty.class.php</code> Smarty 的入口文件，引入此文件即可</li>
<li><code>SmartyBC.class.php</code> 兼容版</li>
</ul>
<p>Smarty.class.php -构造函数</p>
<ul>
<li>setTemplateDir(): 设置模板文件夹</li>
<li>setCompileDir(): 设置混编文件夹</li>
<li>setCacheDir(): 设置缓存文件夹</li>
<li>setConfigsDir(): 设置配置文件夹</li>
</ul>
</blockquote>
<h2 id="使用步骤"><a href="#使用步骤" class="headerlink" title="使用步骤"></a>使用步骤</h2><p>拷贝核心文件libs 到站点下。并更名为Smarty<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">require &apos;./Smarty/Smarty.class.php&apos;;</div><div class="line">$smarty = new Smarty();</div><div class="line">$smarty-&gt;assign(&apos;name&apos;,&apos;uiste&apos;);</div><div class="line">$smarty-&gt;display(&apos;demo1.html&apos;);</div></pre></td></tr></table></figure></p>
<p>界定符：<code>$left_delimiter = &#39;{&#39;</code><br>修改界定符：<code>$smarty-&gt;left_delimiter = &#39;&lt;{&#39;;</code><br>更改模板文件：<code>$smarty-&gt;setTemplateDir(&#39;./views/&#39;);</code><br>更改混编文件夹：<code>$smarty-&gt;setCompileDir(&#39;./view_c/&#39;);</code></p>
<p>注释：<code>{*这是Smarty的注释*}</code><br>多学一招：Smarty和HTML注释内容的区别。Smarty注释在网页源代码中不显示。</p>
<blockquote>
<p>如果Smarty的定界符是<code>{*</code> <code>*}</code>那么注释的语法是?<br>答：<code>{** 注释 **}</code></p>
</blockquote>
<h2 id="变量"><a href="#变量" class="headerlink" title="变量"></a>变量</h2><h3 id="普通变量"><a href="#普通变量" class="headerlink" title="普通变量"></a>普通变量</h3><p>自定义变量。<br>语法一：<br>在PHP文件中，$smarty-&gt;assign(‘变量名’,’变量值’);<br>在模板文件中，<code>{$name}</code><br>语法二：<br>在模板文件中，使用{assign} 标签,定义变量<br><code>{assign var=&#39;name&#39; value=&#39;berry&#39;}</code><br><code>{$name}</code></p>
<h3 id="保留变量"><a href="#保留变量" class="headerlink" title="保留变量"></a>保留变量</h3><p>Smarty 中有一个特殊的变量 <code>$smarty</code> ，不能作为自定义变量名，他是一个保留变量（内置变量）。该变量用来获取用户的请求、系统变量、常量。</p>
<blockquote>
<p>例题</p>
<ul>
<li>模板文件中：<code>{$smarty.get.name}</code> 获取<code>GET</code>、<code>POST</code>、<code>REQUEST</code>提交的值</li>
<li>模板文件中：<code>{$smarty.const.PI}</code> 获取<code>define</code>定义常量</li>
<li>PHP文件中：<code>$_SESSION[&#39;name&#39;] = &#39;root&#39;</code> ；模板文件中：<code>$smarty.session.admin</code> 获取会话的值，<code>$smarty.cookies.admin</code> 获取cookie的值</li>
<li>模板文件中：<code>{$smarty.server.DOCUMENT_ROOT}</code> 获取根目录</li>
<li>模板文件中：<code>{$smarty.now}</code> 获取时间戳</li>
<li>模板文件中：<code>{$smarty.ldelim}</code>，<code>{$smarty.rdelim}</code> 获取左右界定符</li>
<li>模板文件中：<code>{$smarty.version}</code> 获取版本号</li>
</ul>
</blockquote>
<h3 id="配置变量"><a href="#配置变量" class="headerlink" title="配置变量"></a>配置变量</h3><p>将变量保存在配置文件，然后再Smarty模板中引入</p>
<blockquote>
<ol>
<li>新建<code>configs</code>文件夹</li>
<li>创建<code>smarty.conf</code>文件，参数设置如下：<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">&gt;HOST          = 127.0.0.1</div><div class="line">&gt;USERNAME =  ROOT</div><div class="line">&gt;PWD            =  aa</div><div class="line">&gt;[style1]</div><div class="line">&gt;COLOR        =   #FF0000</div><div class="line">&gt;[style2]</div><div class="line">&gt;COLOR        =   #00FF00</div><div class="line">&gt;</div></pre></td></tr></table></figure>
</li>
</ol>
<p>配置文件中<strong>节</strong>，用<code>[]</code>中括号来声明，通过<code>config_load</code> 的 <code>section</code> 属性来引入配置文件中的节，没有经过<code>[]</code>设置为节的为<strong>全局</strong>配置文件</p>
<ol>
<li>模板文件中：<code>{config_load file = &#39;smarty.conf&#39; section=&#39;&#39;}</code> //只需要写配置文件名，不需要写路径</li>
<li>模板文件中，获取数据<br>语法a) ：<br>主机名 用户名</li>
</ol>
</blockquote>
<p>自定义不同情况下的颜色<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">*&#123;</div><div class="line">	color:&#123;##COLOR&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h2 id="数组"><a href="#数组" class="headerlink" title="数组"></a>数组</h2><h3 id="在Smarty中对数组的操作有两种方法"><a href="#在Smarty中对数组的操作有两种方法" class="headerlink" title="在Smarty中对数组的操作有两种方法"></a>在Smarty中对数组的操作有两种方法</h3><p>方法一：{数组[下标]}<br>方法二：{数组.下标}</p>
<h3 id="foreach-循环遍历数组"><a href="#foreach-循环遍历数组" class="headerlink" title="foreach 循环遍历数组"></a>foreach 循环遍历数组</h3><h4 id="语法"><a href="#语法" class="headerlink" title="语法"></a>语法</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">&#123;foreach 数组 as 键=&gt;值&#125;</div><div class="line">//循环体</div><div class="line">&#123;foreachelse&#125;</div><div class="line">//没有数组输出，foreachelse可以省略</div><div class="line">&#123;/foreach&#125;</div></pre></td></tr></table></figure>
<h4 id="属性"><a href="#属性" class="headerlink" title="属性"></a>属性</h4><p>语法：<code>{值变量@属性}</code><br><code>{$value@iteration}</code> 从1开始的编号<br><code>{$value@index}</code> 从0开始的索引<br><code>{$value@first}</code> 是否是第一个元素<br><code>{$value@last}</code> 是否是最后一个元素<br><code>{$value@show}</code> 数组中是否有元素显示<br><code>{$value@total}</code> 一共有多少个元素</p>
<h3 id="section-循环遍历数组"><a href="#section-循环遍历数组" class="headerlink" title="section 循环遍历数组"></a>section 循环遍历数组</h3><p>只能遍历索引数组，不能遍历关联数组</p>
<h4 id="语法："><a href="#语法：" class="headerlink" title="语法："></a>语法：</h4><p><code>{section name = 自定义变量(key)  loop=数组($week)}</code><br>{$week[key]}//循环体<br>{sectionelse}<br>//没有数组输出<br>{/section}</p>
<h4 id="属性-1"><a href="#属性-1" class="headerlink" title="属性"></a>属性</h4><p><code>{$smarty.section.自定义变量名.iteration}</code> 从1增长的编号<br><code>{$smarty.section.自定义变量名.index}</code> 从0增长的索引<br><code>{$smarty.section.自定义变量名.first}</code> 是否是第一个元素<br><code>{$smarty.section.自定义变量名.last}</code> 是否是最后一个元素</p>
<h2 id="判断"><a href="#判断" class="headerlink" title="判断"></a>判断</h2><p>语法：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">&#123;if $score&gt;=90&#125;</div><div class="line">优秀</div><div class="line">&#123;elseif $score&gt;=80&#125;</div><div class="line">良好</div><div class="line">&#123;else $score&gt;=70&#125;</div><div class="line">满意</div><div class="line">&#123;/if&#125;</div></pre></td></tr></table></figure></p>
<h2 id="循环"><a href="#循环" class="headerlink" title="循环"></a>循环</h2><h3 id="for循环"><a href="#for循环" class="headerlink" title="for循环"></a>for循环</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">&#123;for 变量=初始值 to 结束值 [step 步长]&#125;</div><div class="line">//循环体</div><div class="line">&#123;/for&#125;</div></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">&#123;for $i=1 to 10 step 2&#125;</div><div class="line">	&#123;$i&#125;:锄禾日当午</div><div class="line">&#123;/for&#125;</div></pre></td></tr></table></figure>
<blockquote>
<p>步长默认是1，step 自定义步长</p>
<h3 id="while循环"><a href="#while循环" class="headerlink" title="while循环"></a>while循环</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">&#123;while 条件&#125;</div><div class="line">	//循环体</div><div class="line">&#123;/while&#125;</div></pre></td></tr></table></figure>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">&#123;assign var=&apos;n&apos; value=1&#125;</div><div class="line">&#123;while $n&lt;=10&#125;</div><div class="line">	&#123;$n++&#125;:汗滴禾下土</div><div class="line">&#123;/while&#125;</div></pre></td></tr></table></figure>
<h2 id="自定义函数"><a href="#自定义函数" class="headerlink" title="自定义函数"></a>自定义函数</h2><h3 id="html-checkboxes-复选框"><a href="#html-checkboxes-复选框" class="headerlink" title="{html_checkboxes} 复选框"></a>{html_checkboxes} 复选框</h3><p>模板文件中：<br>方法一：<code>{html_checkboxes output=$output values=$values selected=$selected}</code><br>方法二：<code>{html_checkboxes options=$options selected=$selected}</code><br>PHP文件中：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">$smarty-&gt;assign(&apos;output&apos;,array(&apos;ff&apos;,&apos;bb&apos;,&apos;cc&apos;,&apos;dd&apos;,&apos;ee&apos;));</div><div class="line">$smarty-&gt;assign(&apos;value&apos;,array(&apos;1&apos;,&apos;2&apos;,&apos;3&apos;,&apos;4&apos;,&apos;5&apos;));</div><div class="line">$smarty-&gt;assign(&apos;selected&apos;,array(&apos;1&apos;,&apos;4&apos;));</div></pre></td></tr></table></figure></p>
<p>模板文件中<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">&#123;html_checkboxes output=$output values=$value selected=$selected&#125;</div><div class="line">&#123;html_options output=$output values=$value name=&apos;hobby&apos; selected=$selected2&#125;</div><div class="line">&#123;html_radios output=$output values=$value selected=$selected2&#125;</div><div class="line">&#123;html_select_date month_format=&apos;%m&apos; field_order=&apos;YMD&apos;&#125;</div></pre></td></tr></table></figure></p>
<h3 id="html-options-下拉菜单"><a href="#html-options-下拉菜单" class="headerlink" title="{html_options} 下拉菜单"></a>{html_options} 下拉菜单</h3><p>模板文件中：<br><code>{html_options options=$options name=&#39;hobby&#39; selected=$selected}</code><br>PHP文件中：</p>
<h3 id="html-radios-单选按钮"><a href="#html-radios-单选按钮" class="headerlink" title="{html_radios}单选按钮"></a>{html_radios}单选按钮</h3><p>模板文件中：<br><code>{html_radios options=$options selected=$selected}</code></p>
<h3 id="html-select-date-显示日期"><a href="#html-select-date-显示日期" class="headerlink" title="{html_select_date}显示日期"></a>{html_select_date}显示日期</h3><p><code>{html_select_date month_format=&#39;%m&#39; field_order=&#39;YMD&#39;}</code></p>
<h2 id="变量修饰器"><a href="#变量修饰器" class="headerlink" title="变量修饰器"></a>变量修饰器</h2><p>要使用变量修饰器，我们需要管道运算符( | )</p>
<p>在默认情况下，<code>truncate</code>是按字节截取的，但是中文属于多字节字符，在UTF-8下一个字符占用3个字节显示，这样会出现乱码；如果开启了多字节处理，<code>truncate</code>就会自动按多字符处理了。</p>
<blockquote>
<p><code>extension=php_mbstring.dll</code></p>
</blockquote>
<h2 id="缓存"><a href="#缓存" class="headerlink" title="缓存"></a>缓存</h2><h3 id="Smarty-缓存就是生成静态页面"><a href="#Smarty-缓存就是生成静态页面" class="headerlink" title="Smarty 缓存就是生成静态页面"></a>Smarty 缓存就是生成静态页面</h3><p>开启：<code>$smarty-&gt;caching = 1;</code>  开启缓存<br>更新缓存：<br>方法一：删除对应的缓存，系统会更新<br>方法二：更改对应的模板文件，包括配置文件，包含文件，布局文件缓存都会自动更新<br>方法三：缓存文件的有效时间过期，会自动更新<br>方法四：<code>$smarty-&gt;force_cache = true;</code> 强制更新缓存</p>
<h3 id="缓存的生命周期"><a href="#缓存的生命周期" class="headerlink" title="缓存的生命周期"></a>缓存的生命周期</h3><p>默认情况下，缓存的生命周期是3600秒。<br><code>$smarty-&gt;cache_lifetime = -1 | 0 | N;</code></p>
<ul>
<li>N：表示缓存文件生命周期是N秒</li>
<li>0：缓存文件立即失效</li>
<li>-1：永远不失效</li>
</ul>
<h3 id="单模板，多缓存【缓存分页】"><a href="#单模板，多缓存【缓存分页】" class="headerlink" title="单模板，多缓存【缓存分页】"></a>单模板，多缓存【缓存分页】</h3><p>php文件：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">require &apos;./Smarty/Smarty.class.php&apos;;</div><div class="line">$smarty = new Smarty();</div><div class="line">$smarty-&gt;caching = 1; //开启缓存</div><div class="line">$smarty-&gt;display(&apos;demo17.html&apos;,$_GET[&apos;pageno&apos;])</div></pre></td></tr></table></figure></p>
<p>模板文件：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">当前是第&#123;$smarty.get.pageno&#125;页</div></pre></td></tr></table></figure></p>
<h3 id="缓存集合"><a href="#缓存集合" class="headerlink" title="缓存集合"></a>缓存集合</h3><p>PHP代码：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">require &apos;./Smarty/Smarty.class.php&apos;;</div><div class="line">$smarty = new Smarty();</div><div class="line">$smarty-&gt;caching = 1; //开启缓存</div><div class="line">$color = $_GET[&apos;color&apos;];</div><div class="line">$size = $_GET[&apos;size&apos;]</div><div class="line">$smarty-&gt;display(&apos;demo18.html&apos;,&quot;$color|$size&quot;);</div></pre></td></tr></table></figure></p>
<p>模板文件：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">颜色：&#123;$smarty.get.color&#125;</div><div class="line">大小：&#123;$samrty.get.size&#125;</div></pre></td></tr></table></figure></p>
<blockquote>
<p>邓东旭语：厉害了我的哥</p>
</blockquote>
<h3 id="清除缓存"><a href="#清除缓存" class="headerlink" title="清除缓存"></a>清除缓存</h3><p>$smarty-&gt;clearCache(模板，识别id)<br>$smarty-&gt;clearAllCache();  //清楚所有缓存</p>
<p><code>$smarty-&gt;clearCache(&#39;demo18.html&#39;,&#39;red|4&#39;);</code>清除有demeo18.html 模板生成的red 和 4组合的缓存<br>2、$smarty-&gt;clearCache(‘demo18.html’,’red’) : 清除demo18.html 模板生成的带有red的缓存<br>3、$smarty-&gt;clearCache(null,’red’); //清楚所有模板中带有red 的缓存</p>
<p>局部缓存</p>
<p>方法一：如果只有一个变量不缓存使用nocache属性<br>模板文件<code>{$smarty.now nocache}</code></p>
<p>方法二：如果有很多内容不缓存，使用<code>{nocache}</code>标签<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">&#123;nocache&#125;</div><div class="line">一大堆什么鬼东西，是会被动态加载的</div><div class="line">&#123;/nocache&#125;</div></pre></td></tr></table></figure></p>
<h3 id="money"><a href="#money" class="headerlink" title="money"></a>money</h3><p>PHP文件：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">require &apos;./Smarty/Smarty.class.php&apos;;</div><div class="line">$smarty = new Smarty();</div><div class="line">$smarty-&gt;caching = 1; //开启缓存</div><div class="line">$smarty-&gt;display(&apos;demo17.html&apos;,$_GET[&apos;pageno&apos;])</div></pre></td></tr></table></figure></p>
<p>模板文件：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">&lt;style type=&apos;text/css&apos;&gt;</div><div class="line">.aa&#123;</div><div class="line">	color:red;</div><div class="line">&#125;</div><div class="line">&lt;/style&gt;</div><div class="line">&lt;div class=&apos;aa&apos;&gt;锄禾日当午&lt;/div&gt;</div></pre></td></tr></table></figure></p>
<blockquote>
<p>报错问题：源于大括号<code>{}</code>，Smarty将CSS中大括号当成了Smarty的定界符</p>
</blockquote>
<p>解决方法：<br>方法一：更改定界符<br>方法二：在CSS和JS的大括号后面加上一个空格<br>方法三：使用{literal}标签，在literal标签内的大括号不会被解析</p>
<h3 id="Smarty的优点与缺点"><a href="#Smarty的优点与缺点" class="headerlink" title="Smarty的优点与缺点"></a>Smarty的优点与缺点</h3><ol>
<li>因为可以生产缓存，所有速度快</li>
<li>如果要实时更新的内容很多的情况，不适合使用Smarty（比如，股票），如果一个小项目，不适合用</li>
</ol>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/20161011-Library-php-skill.html" itemprop="url">
                  PHP - 速度提升小技巧
                </a>
              
            
          </h1>
        

        <div class="post-meta">
        
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-10-11T22:06:53+08:00" content="2016-10-11">
              2016-10-11
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/20161011-Library-php-skill.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="20161011-Library-php-skill.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="MySQL数据库"><a href="#MySQL数据库" class="headerlink" title="MySQL数据库"></a>MySQL数据库</h1><h2 id="建表"><a href="#建表" class="headerlink" title="建表"></a>建表</h2><p>由于session没有长久保存的必要，所以建议sess表使用memory引擎，此引擎执行效率高。</p>
<h2 id="数据insert"><a href="#数据insert" class="headerlink" title="数据insert"></a>数据insert</h2><h2 id="数据delete"><a href="#数据delete" class="headerlink" title="数据delete"></a>数据delete</h2><h2 id="数据update"><a href="#数据update" class="headerlink" title="数据update"></a>数据update</h2><h2 id="数据select"><a href="#数据select" class="headerlink" title="数据select"></a>数据select</h2><h1 id="PHP"><a href="#PHP" class="headerlink" title="PHP"></a>PHP</h1>
          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/20161011-1.html" itemprop="url">
                  PHP常见错误提示
                </a>
              
            
          </h1>
        

        <div class="post-meta">
        
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-10-11T19:31:45+08:00" content="2016-10-11">
              2016-10-11
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/20161011-1.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="20161011-1.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="Fatal-error-Call-to-undefined-function……"><a href="#Fatal-error-Call-to-undefined-function……" class="headerlink" title="Fatal error: Call to undefined function……"></a>Fatal error: Call to undefined function……</h1><p>函数不存在，可能的原因：<br>1、系统不存在这个函数且你也没自定义<br>2、因为环境不同，这个函数在本环境配置文件没开，百度函数名字，就能查到函数属于哪个dll，在<code>php.ini</code>里开启</p>
<h1 id="syntax-error-unexpected-T-STRING-expecting……"><a href="#syntax-error-unexpected-T-STRING-expecting……" class="headerlink" title="syntax error, unexpected T_STRING, expecting……"></a>syntax error, unexpected T_STRING, expecting……</h1><p>严重语法错误，<br>例如<code>syntax error, unexpected T_STRING, expecting &#39;,&#39; or &#39;;&#39; in F:\phpnow\htdocs\index.php on line 4</code><br>后边标着行号，去检查那一行的标点就行<br>如果是 第三行 echo 1 后边没加;，报错会报 on line 4 </p>
<h1 id="Parse-error-syntax-error-unexpected-T-VARIABLE-in-XXX-php-on-line-XXX"><a href="#Parse-error-syntax-error-unexpected-T-VARIABLE-in-XXX-php-on-line-XXX" class="headerlink" title="Parse error: syntax error, unexpected T_VARIABLE in XXX.php on line XXX"></a>Parse error: syntax error, unexpected T_VARIABLE in XXX.php on line XXX</h1><p>这条语句是PHP常见的报错，一般是在XXX行的上一行，或者是XXX行，缺少分号。或者在双引号中使用双引号，且没有转义等等。<br>解决方法：找到XXX.php的XXX行，按照上面的分析，找到自己的错误，改正即可。</p>
<h1 id="Parse-error-syntax-error-unexpected-‘X’-in-XXX-php-on-line-XXX"><a href="#Parse-error-syntax-error-unexpected-‘X’-in-XXX-php-on-line-XXX" class="headerlink" title="Parse error: syntax error, unexpected ‘X’ in XXX.php on line XXX"></a>Parse error: syntax error, unexpected ‘X’ in XXX.php on line XXX</h1><p>这条语句依然是PHP常见的报错，报错原因是在XXX.php的XXX行，出现了PHP无法识别的字符。常常是因为function，if等需要‘{’、‘}’的地方没有闭合，或者在编程的时候，不小心在‘;’的后面误打了几个字符。<br>解决方法：找到XXX.php的XXX行，删除多出的字符，添加缺少的字符即可。</p>
<h1 id="syntax-error-unexpected-end"><a href="#syntax-error-unexpected-end" class="headerlink" title="syntax error, unexpected $end"></a>syntax error, unexpected $end</h1><p>逻辑忘了闭合  这个报错还有个特征，他会提示你最后一行代码报错，譬如你一共30行，他就告诉你 on line 30，这时候你别检查第三十行，你要把30行挨个，检查一遍，看看哪个标签没闭合。<br>一共3000行，他就告诉你 on line 3000，这时候你别检查这3000行了，如果你程序排版很乱，在3000行里找哪个括号是个很麻烦的事……我教你一招：<br>ctrl+a ctrl+d alt+f4<br>好了，你现在可以重写了。</p>
<h1 id="Notice-Undefined-varialbe-……"><a href="#Notice-Undefined-varialbe-……" class="headerlink" title="Notice:Undefined varialbe:……"></a>Notice:Undefined varialbe:……</h1><p>这是一个比较常见的警告性提示，解决方法：error_reporting调整错误级别，不会调整，那就百度下</p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/">1</a><span class="page-number current">2</span><a class="page-number" href="/page/3/">3</a><span class="space">&hellip;</span><a class="page-number" href="/page/14/">14</a><a class="extend next" rel="next" href="/page/3/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      

      <section class="site-overview sidebar-panel  sidebar-panel-active ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.png"
               alt="uiste" />
          <p class="site-author-name" itemprop="name">uiste</p>
          <p class="site-description motion-element" itemprop="description">Stay Hungry，Stay Foolish</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">70</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              
                <span class="site-state-item-count">13</span>
                <span class="site-state-item-name">分类</span>
              
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">55</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/uiste" target="_blank" rel="external nofollow" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/uiste" target="_blank" rel="external nofollow" title="微博">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  微博
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.zhihu.com/people/uiste" target="_blank" rel="external nofollow" title="知乎">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  知乎
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              友情链接
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.uiste.com" title="uiste 个人博客" target="_blank">uiste 个人博客</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://uiste.github.io" title="uiste 技术博客" target="_blank">uiste 技术博客</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 - 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">uiste</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="http://hexo.io" rel="external nofollow">Hexo</a> 趋势动力
</div>
<!--站长统计-->
<script src="https://s95.cnzz.com/z_stat.php?id=1259894121&web_id=1259894121" language="JavaScript"></script>
<!--<div class="theme-info">
  Theme -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next" rel="external nofollow">
    NexT.Mist
  </a>
</div> -->
&nbsp;&nbsp;&nbsp;本站总点击 <span id="busuanzi_value_site_pv"></span> 次
&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;您是第 <span id="busuanzi_value_site_uv"></span> 位访客

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>

<script>
(function(){
    var bp = document.createElement('script');
    bp.src = '//push.zhanzhang.baidu.com/push.js';
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  

  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"uiste"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    <script src="/vendors/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  






  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
       search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();

    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
    'use strict';
    $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
            // get the contents from search data
            isfetched = true;
            $('.popup').detach().appendTo('.header-inner');
            var datas = $( "entry", xmlResponse ).map(function() {
                return {
                    title: $( "title", this ).text(),
                    content: $("content",this).text(),
                    url: $( "url" , this).text()
                };
            }).get();
            var $input = document.getElementById(search_id);
            var $resultContent = document.getElementById(content_id);
            $input.addEventListener('input', function(){
                var matchcounts = 0;
                var str='<ul class=\"search-result-list\">';
                var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                $resultContent.innerHTML = "";
                if (this.value.trim().length > 1) {
                // perform local searching
                datas.forEach(function(data) {
                    var isMatch = true;
                    var content_index = [];
                    var data_title = data.title.trim().toLowerCase();
                    var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                    var data_url = data.url;
                    var index_title = -1;
                    var index_content = -1;
                    var first_occur = -1;
                    // only match artiles with not empty titles and contents
                    if(data_title != '' && data_content != '') {
                        keywords.forEach(function(keyword, i) {
                            index_title = data_title.indexOf(keyword);
                            index_content = data_content.indexOf(keyword);
                            if( index_title < 0 && index_content < 0 ){
                                isMatch = false;
                            } else {
                                if (index_content < 0) {
                                    index_content = 0;
                                }
                                if (i == 0) {
                                    first_occur = index_content;
                                }
                            }
                        });
                    }
                    // show search results
                    if (isMatch) {
                        matchcounts += 1;
                        str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                        var content = data.content.trim().replace(/<[^>]+>/g,"");
                        if (first_occur >= 0) {
                            // cut out 100 characters
                            var start = first_occur - 20;
                            var end = first_occur + 80;
                            if(start < 0){
                                start = 0;
                            }
                            if(start == 0){
                                end = 50;
                            }
                            if(end > content.length){
                                end = content.length;
                            }
                            var match_content = content.substring(start, end);
                            // highlight all keywords
                            keywords.forEach(function(keyword){
                                var regS = new RegExp(keyword, "gi");
                                match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                            });

                            str += "<p class=\"search-result\">" + match_content +"...</p>"
                        }
                        str += "</li>";
                    }
                })};
                str += "</ul>";
                if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
                if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
                $resultContent.innerHTML = str;
            });
            proceedsearch();
        }
    });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };

    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>


  

  

  

</body>
</html>
